#pragma once
#include <iostream>
class CharNode
{
public:
	char data;
	CharNode* next;
	CharNode() {};
	~CharNode() {};
};

class Char_queue
{
public:
	Char_queue() :tail(&head_node) 
		{ head_node.data = '0'; head_node.next = nullptr; };
	~Char_queue() {};
	bool isEmpty() const { return tail == &head_node; }
	bool isFull() const { return false; }
	char dequeue();		//出队
	void enqueue(char );		//入队
	void print() const;
private:
	CharNode head_node;
	CharNode* tail;
};

inline void Char_queue::enqueue(char ch) {
	if (isFull()) throw("The qurur is FULL!");
	std::cout << "正在入队：" << ch << std::endl;
	CharNode* newNode = new CharNode();
	newNode->data = ch;
	newNode->next = nullptr;
	tail->next = newNode;
	tail = tail->next;
	head_node.data = char(int(head_node.data) + 1);
	std::cout << "入队完毕：" << tail->data << std::endl;
}

inline char Char_queue::dequeue() {
	if (isEmpty()) throw("The qurur is EMPTY!");
	char reChar = head_node.next->data;
	head_node.next = head_node.next->next;
	if (head_node.next==nullptr) {
		tail = &head_node;
	}
	head_node.data = char(int(head_node.data) - 1);
	std::cout << "出队完毕：";
	return reChar;
}

inline void Char_queue::print() const {
	if (isEmpty()) {
		std::cout << "队列为空！" << std::endl;
		return;
	}
	else {
		std::cout << "当前队列有"<<head_node.data<<"个元素：";
	}
	CharNode* currNode = head_node.next;

	while (currNode!=nullptr){
		std::cout << currNode->data << '!';
		currNode = currNode->next;
	}
	std::cout << std::endl;
}